<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
    String path = request.getContextPath();
%>

<jsp:include page="/admin/inc/incHead.jsp" flush="false"/>
    <script language="javascript">
        function goodDel(goodId) {
            if(!goodId){alert("网页存在错误")}
            if (confirm('您确定删除吗？')) {
                window.location.href = "<%=path %>/good/goodDel.action?goodId=" + goodId;
            }
        }

        function over(picPath) {
            if (picPath == "")picPath = "/images/default.jpg";
            var elem = $('#tip')[0];
            var img = $('#tip img')[0];
            var x = event.clientX;
            var y = event.clientY;
            img.src = '<%=path %>'+picPath;
            $('#tip img').load(function () {
                var h=y+$('#tip').height()-$(window.document).height();
                if(h>-40)y-=h+40;
                elem.style.top = y;
                elem.style.left = x + 10;
                elem.style.display = "block";
            })
        }
        function out() {
            $('#tip')[0].style.display = "none";
        }
        $(window.document).ready(function () {
            $('#btn-pic').tooltip({
                html: true,
                template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow">图片</div><div class="tooltip-inner"></div></div>'
            })

        });
    </script>
<div id="tip" class="panel panel-default" style="position: fixed;display: none;padding: 5px;max-width: 400px; overflow: hidden;">
    <img src="" style="max-width: 380px;position: static;"/>
</div>
<table align="center" class="table table-bordered">
    <tr bgcolor="#E7E7E7">
        <td height="14" colspan="9" background="<%=path %>/images/tbg.gif">&nbsp;商品管理&nbsp;</td>
    </tr>
    <tr align="center" bgcolor="#FAFAF1" height="22">
        <td width="10%">名称</td>
        <td width="10%">类别</td>
        <td width="10%">图片</td>
        <td width="10%">价格</td>
        <td width="10%">状态</td>
        <td width="10%">库存</td>
        <td width="10%">销量</td>
        <td width="10%">介绍</td>
        <td width="10%">操作</td>
    </tr>
    <s:iterator value="#request.goodItems" var="item">
        <tr align='center' bgcolor="#FFFFFF">
            <td bgcolor="#FFFFFF" align="center">
                <s:property value="#item.good.goodName"/>
            </td>
            <td bgcolor="#FFFFFF" align="center">
                <s:property value="#item.clazz.className"/>
            </td>
            <td bgcolor="#FFFFFF" align="center">
                <div onmouseenter="over('<%=path %><s:property value="#item.good.goodPic"/>')" onmouseout="out()"
                     style="cursor:hand;">
                    查看图片
                </div>
            </td>
            <td bgcolor="#FFFFFF" align="center">
                <s:property value="#item.good.goodPrice"/>
            </td>
            <td bgcolor="#FFFFFF" align="center">
                <s:if test="#item.good.goodState==0">
                    已下架
                </s:if>
                <s:if test="#item.good.goodState==1">
                    销售中
                </s:if>
            </td>
            <td bgcolor="#FFFFFF" align="center">
                <s:property value="#item.good.goodInventory"/>
            </td>
            <td bgcolor="#FFFFFF" align="center">
                <s:property value="#item.good.goodSell"/>
            </td>
            <td bgcolor="#FFFFFF" align="center">
                <!-- Button trigger modal -->
                <button type="button" class="btn btn-Info" onclick="modal(this,'点卡详情')">
                    <strong>介绍详情</strong>
                    <div class="modal-info" style="display: none;">
                        <s:property value="#item.good.goodInfo" escapeHtml="false"/>
                    </div>
                </button>
            </td>
            <td bgcolor="#FFFFFF" align="center">
                <a href="/good/goodEditPage.action?goodId=<s:property value="#item.good.goodId"/>">修改</a>
                <a href="#" onclick="goodDel(<s:property value="#item.good.goodId"/>)" >删除</a>
            </td>
        </tr>
    </s:iterator>
</table>
<jsp:include page="/common/page.jsp" flush="true"/>
<jsp:include page="/admin/inc/incFoot.jsp" flush="false"/>
